package net.yunxinyong.cec.controller;

import net.yunxinyong.cec.entity.Cec711FiveFinanceWages;
import net.yunxinyong.cec.service.Cec711FiveFinanceService;
import net.yunxinyong.cec.utils.CECResult;
import net.yunxinyong.cec.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 李跃
 * @date 18/9/18
 */
@RequestMapping(value = "711five")
@RestController
public class Cec711FiveContoller {
    @Autowired
    private Cec711FiveFinanceService cec711FiveFinanceService;

    @PostMapping(value = "add")
    public CECResult insertFive(@RequestBody Cec711FiveFinanceWages cec711FiveFinanceWages){
        Cec711FiveFinanceWages cec711FiveFinanceWages1 = cec711FiveFinanceService.insertFive(cec711FiveFinanceWages);

        if(cec711FiveFinanceWages1 == null){
            return CECResult.build(500,"企业信息已存在");
        }
        return CECResult.build(200,"企业信息添加成功",cec711FiveFinanceWages1);
    }

    @GetMapping("delete")
    public CECResult deleteFive(@RequestParam(value = "id") Integer id){
        int i = cec711FiveFinanceService.deleteFive(id);
        if(i > 0 ){
            return CECResult.build(200,"企业信息删除成功");
        }
        return CECResult.build(500,"企业信息删除失败");
    }

    @PostMapping(value = "update")
    public CECResult updateFive(@RequestBody Cec711FiveFinanceWages cec711FiveFinanceWages){
        int i = cec711FiveFinanceService.updateFive(cec711FiveFinanceWages);
        if(i > 0){
            return     CECResult.build(200,"企业信息更新更成功");
        }
            return  CECResult.build(500,"企业信息更新失败");
    }

    @PostMapping(value = "getFive/{page}/{rows}")
    public CECResult inserFive(@RequestBody Cec711FiveFinanceWages cec711FiveFinanceWages,@PathVariable int page, @PathVariable int rows ){
        PageBean pageBean = cec711FiveFinanceService.ListFvieByname(cec711FiveFinanceWages, page, rows);
        if(pageBean.getPageDatas().isEmpty()){
            return     CECResult.build(500,"没有查询到企业信息",pageBean);
        }
        return  CECResult.build(200,"查询到了企业信息",pageBean);

    }

}
